﻿@using SCMS.Resource
@model SCMS.UI.Models.Project
@{AjaxOptions ajaxOpts = new AjaxOptions { UpdateTargetId = "budgetDiv", LoadingElementId = "loading", HttpMethod = "Post", Url = Url.Action("SaveProject") };}
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

<div class="partialViewCard">
<div class="partialViewCardHeader"><h3>@ViewBag.FormHeader</h3></div>
@using (Ajax.BeginForm(null, null, ajaxOpts, new { @class = "form" }))
{ 
    <br />
    <table width="98%" align="center" cellpadding="0" style="margin-left: auto; margin-right: auto;">
        <tr>
            <th width="34%">
                @Resources.Budget_CreateProject_ProjectName
            </th>
            <th width="33%">
                @Resources.Global_String_ShortName
            </th>
            <th width="33%">
                @Resources.Budget_CreateProject_ProjectNumber
            </th>
        </tr>
        <tr>
            <td>
                @Html.TextBoxFor(p => p.ProjectName, new { id = "projectName", name = "projectName"})
                @Html.ValidationMessageFor(p => p.ProjectName)
                <script type="text/javascript">
                    var $jq = jQuery.noConflict();
                    $jq("#projectName").autocomplete("/Budget/SearchProjects");
                </script>
            </td>
            <td>
                @Html.TextBoxFor(p => p.EntityProject.ShortName)
            </td>
            <td>
                @Html.TextBoxFor(p => p.ProjectNumber) 
                @Html.ValidationMessageFor(p => p.ProjectNumber)
            </td>
        </tr>
        <tr>
            <th>@Resources.Budget_CreateProject_ProjectManager</th>
            <th>@Resources.Budget_CategoryList_Donor</th>
            <th>@Resources.Budget_CategoryList_Currency</th>
        </tr>
        <tr>
            <td>
                @Html.DropDownListFor(p => p.ProjectManagerId, Model.StaffList)                    
                @Html.ValidationMessageFor(p => p.ProjectManagerId)
            </td>
            <td>
                @Html.DropDownListFor(p => p.DonorId, Model.Donors)                    
                @Html.ValidationMessageFor(p => p.DonorId)
            </td>
            <td>
                @Html.DropDownListFor(p => p.CurrencyId, Model.Currencies)                    
                @Html.ValidationMessageFor(p => p.CurrencyId)
            </td>
        </tr>
        <tr>
            <th>@Resources.Budget_CreateProject_StartDate</th>
            <th>@Resources.Budget_CreateProject_EndDate</th>
            <th>@Resources_frank.Budget_CreateProject_AllowedOverrun</th>
        </tr>
        <tr>
            <td>
                @Html.EditorFor(p => p.StartDate)
                @Html.ValidationMessageFor(p => p.StartDate)
            </td>
            <td>
                @Html.EditorFor(p => p.EndDate)                    
                @Html.ValidationMessageFor(p => p.EndDate)
            </td>
            <td>
                @Html.TextBoxFor(p => p.OverrunAdjustment, new { @class = "numericTb"})
                @Html.ValidationMessageFor(p => p.OverrunAdjustment)           
            </td>
        </tr>
        <tr>
            <td>
                @Html.HiddenFor(p => p.Id)
                @Html.HiddenFor(p => p.EntityProject.Id)
                <input type="submit" class="btn green"  value="@ViewBag.ButtonText" />
            </td>
            <td align="center">
                @if (ViewBag.EditMode == 1 && UserContext.HasPermission(StandardPermissionProvider.ProjectApproversView))
                {
                    @Ajax.ActionLink(Resources.Budget_CreateProject_ApprovalSettings, "ApprovalSettings", new { id = ViewBag.Id }, new AjaxOptions
                    {
                        UpdateTargetId = "budgetDiv",
                        LoadingElementId = "loading",
                        Url = Url.Action("ApprovalSettings/" + ViewBag.Id),
                        OnSuccess = "initTabs(0);"
                    })
                    <br />
                }     
                @if (ViewBag.Status == 1)
                { 
                    <font color="green">@Resources.Budget_CreateProject_SavedSuccessfully</font>
                }
                @if (ViewBag.Status == 0)
                { 
                    <font color="red">@string.Format(Resources.Budget_CreateProject_NumberExists, ViewBag.ProjectNumber)</font>
                }
            </td>
            <td align="right">
                @if (ViewBag.EditMode == 1)
                {
                    if (ViewBag.HasBudget == 1)
                    {
                        @Ajax.ActionLink(Resources.Budget_LinkToMB_EditBudget, "Index", new { id = "Edit" }, new AjaxOptions
                   {
                       UpdateTargetId = "budgetDiv",
                       LoadingElementId = "loading",
                       Url = Url.Action("CategoryList/" + ViewBag.Id)
                   })
                    }
                    if (ViewBag.HasBudget == 0)
                    {
                        @Ajax.ActionLink(Resources.Budget_CreateProject_ProceedToCreateBudget, "Index", new { id = "Edit" }, new AjaxOptions
                   {
                       UpdateTargetId = "budgetDiv",
                       LoadingElementId = "loading",
                       Url = Url.Action("CategoryList/" + ViewBag.Id)
                   }, new { @class = "btn" })
                    }
                }
            </td>
        </tr>
    </table>
    <br />
}    
</div>    
    
